<?php
require 'mailer/PHPMailerAutoload.php';

//Create a new PHPMailer instance
$mail = new PHPMailer();
// Set PHPMailer to use the sendmail transport
$mail->isSendmail();
//Set who the message is to be sent from
$mail->setFrom('no-reply@geministaller.com', 'Consulta');
//Set an alternative reply-to address
$mail->addReplyTo($_POST['email'], $_POST['name']);
//Set who the message is to be sent to
$mail->addAddress('helldaemon@gmail.com', 'hell');
//Set the subject line
$mail->Subject = 'Consulta de '.$_POST['name'];
//Read an HTML message body from an external file, convert referenced images to embedded,
//convert HTML into a basic plain-text alternative body
//$mail->msgHTML(file_get_contents('contents.html'), dirname(__FILE__));
$mail->msgHTML($_POST['name'].'<br/>'.$_POST['email'].'<br/>'.$_POST['phone'].'<br/>'.$_POST['menssage']);
//Replace the plain text body with one created manually
$mail->AltBody = $_POST['name'].' - '.$_POST['email'].' - '.$_POST['phone'].' - '.$_POST['menssage'];
//Attach an image file
//$mail->addAttachment('images/phpmailer_mini.gif');

//send the message, check for errors
if (!$mail->send()) {
    //echo "Mailer Error: " . $mail->ErrorInfo;
	echo json_encode(array("error"=> "Mensaje no enviado, intente de nuevo por favor.". $mail->ErrorInfo));
} else {
    echo json_encode(array('success'=>"Mensaje enviado!. En breve nos pondremos en contacto con usted."));
}
?>